{{ 'component-image-with-text.css' | asset_url | stylesheet_tag }}
<div class="app-text">
    <div class="image-with-text {% if section.settings.full_width %}image-with-text--full-width{% else %}page-width{% endif %} color-scheme-{{ section.settings.color_scheme }}">
        <div class="image-with-text__grid color-{{ section.settings.color_scheme }} grid grid--gapless grid--1-col grid--2-col-tablet gradient{% if section.settings.layout == 'text_first' %} image-with-text__grid--reverse{% endif %}">
          <div class="grid__item">
            <div class="block-image pc-banner image-with-text__media image-with-text__media--{{ section.settings.height }} {% if section.settings.image != blank %}media{% else %}image-with-text__media--placeholder placeholder{% endif %}"
              {% if section.settings.height == 'adapt' and section.settings.image != blank %} style="padding-bottom: {{ 1 | divided_by: section.settings.image.aspect_ratio | times: 100 }}%;"{% endif %}
            >
              {%- if section.settings.image != blank -%}
                <img
                  srcset="
                   {%- if section.settings.image.width >= 323 -%}{{ section.settings.image | img_url: '323x' }} 323w,{%- endif -%}
                   {%- if section.settings.image.width >= 360 -%}{{ section.settings.image | img_url: '750x' }} 750w,{%- endif -%}
                   {%- if section.settings.image.width >= 539 -%}{{ section.settings.image | img_url: '2500x' }} 2500w,{%- endif -%}
                    {%- if section.settings.image.width >= 750 -%}{{ section.settings.image | img_url: '2500x' }} 2500w,{%- endif -%}
                    {%- if section.settings.image.width >= 1070 -%}{{ section.settings.image | img_url: '2500x' }} 2500w,{%- endif -%}
                    {%- if section.settings.image.width >= 1500 -%}{{ section.settings.image | img_url: '2500x' }} 2500w,{%- endif -%}
                    {%- if section.settings.image.width >= 2000 -%}{{ section.settings.image | img_url: '2500x' }} 2500w,{%- endif -%}
                  {%- if section.settings.image.width >= 2500 -%}{{ section.settings.image | img_url: '2500x' }} 2500w,{%- endif -%}
                    {{ section.settings.image | img_url: 'master' }} {{ section.settings.image.width }}w"
                    src="{{ section.settings.image | img_url: '750x' }}"
                    data-src="{{ section.settings.image | img_url: '750x' }}"
                  sizes="(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | divided_by: 3 }}px, (min-width: 750px) calc((100vw - 130px) / 2), calc((100vw - 50px) / 2)"
                  alt="{{ section.settings.image.alt | escape }}"
                  loading="lazy"
                  class="lazyload img_0"
                  width="{{ section.settings.image.width }}"
                  height="{{ section.settings.image.height }}"
                >
              {%- else -%}
                {{ 'image' | placeholder_svg_tag: 'placeholder-svg' }}
              {%- endif -%}
             
            {%- if section.settings.image_1 != blank -%}
            <img
              srcset="
               {%- if section.settings.image_1.width >= 323 -%}{{ section.settings.image_1 | img_url: '323x' }} 323w,{%- endif -%}
               {%- if section.settings.image_1.width >= 360 -%}{{ section.settings.image_1 | img_url: '750x' }} 750w,{%- endif -%}
               {%- if section.settings.image_1.width >= 539 -%}{{ section.settings.image_1 | img_url: '2500x' }} 2500w,{%- endif -%}
                {%- if section.settings.image_1.width >= 750 -%}{{ section.settings.image_1 | img_url: '2500x' }} 2500w,{%- endif -%}
                {%- if section.settings.image_1.width >= 1070 -%}{{ section.settings.image_1 | img_url: '2500x' }} 2500w,{%- endif -%}
                {%- if section.settings.image_1.width >= 1500 -%}{{ section.settings.image_1 | img_url: '2500x' }} 2500w,{%- endif -%}
                {%- if section.settings.image_1.width >= 2000 -%}{{ section.settings.image_1 | img_url: '2500x' }} 2500w,{%- endif -%}
              {%- if section.settings.image_1.width >= 2500 -%}{{ section.settings.image_1 | img_url: '2500x' }} 2500w,{%- endif -%}
                {{ section.settings.image_1 | img_url: 'master' }} {{ section.settings.image_1.width }}w"
                src="{{ section.settings.image_1 | img_url: '750x' }}"
                data-src="{{ section.settings.image_1 | img_url: '750x' }}"
              sizes="(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | divided_by: 3 }}px, (min-width: 750px) calc((100vw - 130px) / 2), calc((100vw - 50px) / 2)"
              alt="{{ section.settings.image_1.alt | escape }}"
              loading="lazy"
              class="lazyload img_1"
              width="{{ section.settings.image_1.width }}"
              height="{{ section.settings.image_1.height }}"
            >
          {%- else -%}
            {{ 'image' | placeholder_svg_tag: 'placeholder-svg' }}
          {%- endif -%}
          {%- if section.settings.image_2 != blank -%}
          <img
            srcset="
             {%- if section.settings.image_2.width >= 323 -%}{{ section.settings.image_2 | img_url: '323x' }} 323w,{%- endif -%}
             {%- if section.settings.image_2.width >= 360 -%}{{ section.settings.image_2 | img_url: '750x' }} 750w,{%- endif -%}
             {%- if section.settings.image_2.width >= 539 -%}{{ section.settings.image_2 | img_url: '2500x' }} 2500w,{%- endif -%}
              {%- if section.settings.image_2.width >= 750 -%}{{ section.settings.image_2 | img_url: '2500x' }} 2500w,{%- endif -%}
              {%- if section.settings.image_2.width >= 1070 -%}{{ section.settings.image_2 | img_url: '2500x' }} 2500w,{%- endif -%}
              {%- if section.settings.image_2.width >= 1500 -%}{{ section.settings.image_2 | img_url: '2500x' }} 2500w,{%- endif -%}
              {%- if section.settings.image_2.width >= 2000 -%}{{ section.settings.image_2 | img_url: '2500x' }} 2500w,{%- endif -%}
            {%- if section.settings.image_2.width >= 2500 -%}{{ section.settings.image_2 | img_url: '2500x' }} 2500w,{%- endif -%}
              {{ section.settings.image_2 | img_url: 'master' }} {{ section.settings.image_2.width }}w"
              data-src="{{ section.settings.image_2 | img_url: '750x' }}"
            sizes="(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | divided_by: 3 }}px, (min-width: 750px) calc((100vw - 130px) / 2), calc((100vw - 50px) / 2)"
            alt="{{ section.settings.image_2.alt | escape }}"
            loading="lazy"
            class="lazyload img_2"
            width="{{ section.settings.image_2.width }}"
            height="{{ section.settings.image_2.height }}"
          >
        {%- else -%}
          {{ 'image' | placeholder_svg_tag: 'placeholder-svg' }}
        {%- endif -%}
            </div>
             <div class="mb-banner image-with-text__media image-with-text__media--{{ section.settings.height }} {% if section.settings.image_mobile != blank %}media{% else %}image-with-text__media--placeholder placeholder{% endif %}"
        {% if section.settings.image_mobile != blank %} style="padding-bottom: {{ 1 | divided_by: section.settings.image_mobile.aspect_ratio | times: 100 }}%;"{% endif %}
      >
        {%- if section.settings.image_mobile != blank -%}
          <img
            srcset="{%- if section.settings.image_mobile.width >= 165 -%}{{ section.settings.image_mobile | img_url: '165x' }} 165w,{%- endif -%}
              {%- if section.settings.image_mobile.width >= 323 -%}{{ section.settings.image_mobile | img_url: '323x' }} 323w,{%- endif -%}
              {%- if section.settings.image_mobile.width >= 360 -%}{{ section.settings.image_mobile | img_url: '360x' }} 360w,{%- endif -%}
              {%- if section.settings.image_mobile.width >= 535 -%}{{ section.settings.image_mobile | img_url: '535x' }} 535w,{%- endif -%}
              {%- if section.settings.image_mobile.width >= 750 -%}{{ section.settings.image_mobile | img_url: '750x' }} 750w,{%- endif -%}
              {%- if section.settings.image_mobile.width >= 1070 -%}{{ section.settings.image_mobile | img_url: '1070x' }} 1070w,{%- endif -%}
              {%- if section.settings.image_mobile.width >= 1500 -%}{{ section.settings.image_mobile | img_url: '1500x' }} 1500w,{%- endif -%}
              {{ section.settings.image_mobile | img_url: 'master' }} {{ section.settings.image_mobile.width }}w"
            src="{{ section.settings.image_mobile | img_url: '1500x' }}"
            data-src="{{ section.settings.image_mobile | img_url: '1500x' }}"
            sizes="(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | divided_by: 1 }}px, (min-width: 750px) calc((100vw - 130px) / 1), calc((100vw - 50px) / 1)"
            alt="{{ section.settings.image_mobile.alt | escape }}"
            loading="lazy"
            width="{{ section.settings.image_mobile.width }}"
            height="{{ section.settings.image_mobile.height }}"
          >
        {%- else -%}
          {{ 'image' | placeholder_svg_tag: 'placeholder-svg' }}
        {%- endif -%}
             </div>
             <div class="middle-image">
              {%- for block in section.blocks -%}
                {% case block.type %}
                {%- when 'image' -%}
                   {% if block.settings.image != blank %}
                      <img class="img_{{ forloop.index0 }}" src="{{ block.settings.image | img_url: '750x' }}"  alt="{{ block.settings.image | escape }}" loading="lazy">
                   {% endif %}
                {%- endcase -%}
              {%- endfor -%}    
            </div>
          </div>
          <div class="grid__item">
            <div class="page-width image-with-text__content image-with-text__content--{{ section.settings.height }}">
              {%- for block in section.blocks -%}
                {% case block.type %}
                  {%- when 'heading' -%}
                    <h2 class="image-with-text__heading h1" {{ block.shopify_attributes }}>
                     {% if block.settings.heading != blank %}
                       {{ block.settings.heading | escape }}
                     {% endif %}
                      {% if block.settings.heading_1 != blank %}
                        {{ block.settings.heading_1 }}
                     {% endif %}
                    </h2>
                  {%- when 'text' -%}
                    <div class="content-text image-with-text__text rte" {{ block.shopify_attributes }}>{{ block.settings.text }}</div>
                  {%- when 'app-text' -%}
                      <div class="app_text-block" {{ block.shopify_attributes }}>
                        {% if block.settings.text_1 != blank %}
                        <div class="text_1 image-with-text__text rte">
                          {{ block.settings.text_1 }}
                          </div>
                        {% endif %}
                        {% if block.settings.text_2 != blank %}
                        <div class="text_2 image-with-text__text rte">
                          {{ block.settings.text_2 }}
                          </div>
                        {% endif %}
                        {% if block.settings.text_3 != blank %}
                        <div class="text_3 image-with-text__text rte">
                          {{ block.settings.text_3 }}
                          </div>
                        {% endif %}
                      </div>
                  {%- when 'button' -%}
                    {%- if block.settings.button_label != blank -%}
                      <a{% if block.settings.button_link != blank %} href="{{ block.settings.button_link }}"{% endif %} class="button{% if block.settings.button_style_secondary %} button--secondary{% else %} button--primary{% endif %}"{% if block.settings.button_link == blank %} aria-disabled="true"{% endif %} {{ block.shopify_attributes }}>
                        {{ block.settings.button_label | escape }}
                      </a>
                    {%- endif -%}
                    <div class="app-img">
                        <span>{% render 'app-store' %}</span>
                        <span>{% render 'google-play' %}</span>
                    </div>
                    {%- when 'app' -%}
                      <div class="app-img">
                          <span>
                            <img loading="lazy" src="https://cdn.shopifycdn.net/s/files/1/0592/2167/2098/files/app-store.png?v=1673338992" style="max-width:120px;margin:0;" alt="">
                          </span>
                          <span>
                            <img loading="lazy" src="https://cdn.shopifycdn.net/s/files/1/0592/2167/2098/files/google-play.png?v=1673338992" style="max-width:135px" alt="">
                          </span>
                      </div>
                {%- endcase -%}
              {%- endfor -%}
            </div>
          </div>
        </div>
    </div>
</div>

<script>
  $(window).ready(function() {
    var tooSmall = false;
    var controller = null;
    var maxWidth = 991;
  
    if( $(window).width() < maxWidth ) {
      tooSmall = true;
    }


    function initScrollMagic() {

    const appImage = document.querySelector(".app-image");
    const appImg = appImage.querySelectorAll(".middle-image img");
    const appText = appImage.querySelectorAll(".app_text-block .rte");

      const AiController = new ScrollMagic.Controller();

         let scene = new ScrollMagic.Scene({
          duration: 2000,
          triggerElement: appImage,
          triggerHook: 0
          })
         .setPin(appImage)         
         .addTo(AiController);
  

         var appImgslide = new TimelineMax()
         .add(TweenMax.to(".app-image", 1, {top: "0%", ease: Bounce.easeOut }))
         .add([
             TweenMax.to(".middle-image .img_0", 1, {display:'none'}),
             TweenMax.from(".middle-image .img_1", 1, {display:'none'}),
          ])
          .add([
            TweenMax.to(".middle-image .img_1", 1, {display:'none'}),
            TweenMax.from(".middle-image .img_2", 1, {display:'none'}),
         ])

         var appImagelide = new TimelineMax()
         .add(TweenMax.to(".block-image", 1, {top: "0%", ease: Bounce.easeOut }))
         .add([
             TweenMax.to(".block-image .img_0", 1, {display:'none'}),
             TweenMax.from(".block-image .img_1", 1, {display:'none'}),
          ])
          .add([
            TweenMax.to(".block-image .img_1", 1, {display:'none'}),
            TweenMax.from(".block-image .img_2", 1, {display:'none'}),
         ])
  
         var appTextslide = new TimelineMax()
         .add([
             TweenMax.to(".app_text-block .text_1", 1, {opacity: .15}),
             TweenMax.from(".app_text-block .text_2", 1, {opacity: .15}),
          ])
          .add([
            TweenMax.to(".app_text-block .text_2", 1, {opacity: .15}),
            TweenMax.from(".app_text-block .text_3", 1, {opacity: .15}),
         ])
        
  
          let scene1 = new ScrollMagic.Scene({
            duration: 2100,
            triggerElement: appImage,
            triggerHook: 0
          })
          .setTween(appImgslide)
          .addTo(AiController);

          let scene3 = new ScrollMagic.Scene({
            duration: 2100,
            triggerElement: appImage,
            triggerHook: 0
          })
          .setTween(appImagelide)
          .addTo(AiController);

          let scene2 = new ScrollMagic.Scene({
            duration: 2100,
            triggerElement: appImage,
            triggerHook: 0
          })
          .setTween(appTextslide)
          .addTo(AiController);

       }
    
      if( !tooSmall ) {
        initScrollMagic();
      }

    $(window).resize( function() {
      var wWidth = $(window).width();
      if( wWidth < maxWidth ) {
        if( AiController !== null && AiController !== undefined ) {
          AiController = AiController.destroy( true );
        }
      } else if( wWidth >= maxWidth ) {
        if( AiController === null || AiController === undefined ) {
          initScrollMagic();
        }
      }
    });
  })
</script>  



{% schema %}
{
  "name": "App image text",
  "class": "spaced-section spaced-section--full-width app-image app-image-text",
  "settings": [
    {
      "type": "image_picker",
      "id": "image",
      "label": "t:sections.image-with-text.settings.image.label"
    },
    {
      "type": "image_picker",
      "id": "image_1",
      "label": "image_1"
    },
    {
      "type": "image_picker",
      "id": "image_2",
      "label": "image_2"
    },
    {
        "type": "image_picker",
        "id": "image_mobile",
        "label": "Mobile image"
    },
    {
      "type": "select",
      "id": "height",
      "options": [
        {
          "value": "adapt",
          "label": "t:sections.image-with-text.settings.height.options__1.label"
        },
        {
          "value": "small",
          "label": "t:sections.image-with-text.settings.height.options__2.label"
        },
        {
          "value": "large",
          "label": "t:sections.image-with-text.settings.height.options__3.label"
        }
      ],
      "default": "adapt",
      "label": "t:sections.image-with-text.settings.height.label"
    },
    {
      "type": "select",
      "id": "color_scheme",
      "options": [
        {
          "value": "background-1",
          "label": "t:sections.image-with-text.settings.color_scheme.options__1.label"
        },
        {
          "value": "background-2",
          "label": "t:sections.image-with-text.settings.color_scheme.options__2.label"
        },
        {
          "value": "inverse",
          "label": "t:sections.image-with-text.settings.color_scheme.options__3.label"
        },
        {
          "value": "accent-1",
          "label": "t:sections.image-with-text.settings.color_scheme.options__4.label"
        },
        {
          "value": "accent-2",
          "label": "t:sections.image-with-text.settings.color_scheme.options__5.label"
        }
      ],
      "default": "background-1",
      "label": "t:sections.image-with-text.settings.color_scheme.label"
    },
    {
      "type": "select",
      "id": "layout",
      "options": [
        {
          "value": "image_first",
          "label": "t:sections.image-with-text.settings.layout.options__1.label"
        },
        {
          "value": "text_first",
          "label": "t:sections.image-with-text.settings.layout.options__2.label"
        }
      ],
      "default": "image_first",
      "label": "t:sections.image-with-text.settings.layout.label",
      "info": "t:sections.image-with-text.settings.layout.info"
    }
  ],
  "blocks": [
    {
      "type": "heading",
      "name": "t:sections.image-with-text.blocks.heading.name",
      "limit": 1,
      "settings": [
        {
          "type": "text",
          "id": "heading",
          "default": "Image with text",
          "label": "t:sections.image-with-text.blocks.heading.settings.heading.label"
        },
        {
          "type": "richtext",
          "id": "heading_1",
          "label": "Heading 1"
        }
      ]
    },
    {
      "type": "text",
      "name": "t:sections.image-with-text.blocks.text.name",
      "limit": 1,
      "settings": [
        {
          "type": "richtext",
          "id": "text",
          "default": "<p>Pair text with an image to focus on your chosen product, collection, or blog post. Add details on availability, style, or even provide a review.</p>",
          "label": "t:sections.image-with-text.blocks.text.settings.text.label"
        }
      ]
    },
    {
      "type": "app-text",
      "name": "app-text",
      "limit": 1,
      "settings": [
        {
          "type": "richtext",
          "id": "text_1",
          "label": "text_1"
        },
        {
          "type": "richtext",
          "id": "text_2",
          "label": "text_2"
        },
        {
          "type": "richtext",
          "id": "text_3",
          "label": "text_3"
        }
      ]
    },
    {
      "type": "button",
      "name": "t:sections.image-with-text.blocks.button.name",
      "limit": 1,
      "settings": [
        {
          "type": "text",
          "id": "button_label",
          "default": "Button label",
          "label": "t:sections.image-with-text.blocks.button.settings.button_label.label",
          "info": "t:sections.image-with-text.blocks.button.settings.button_label.info"
        },
        {
          "type": "url",
          "id": "button_link",
          "label": "t:sections.image-with-text.blocks.button.settings.button_link.label"
        }
      ]
    },
    {
      "type": "app",
      "name": "app",
      "limit": 1
    },
     {
      "type": "image",
      "name": "image",
      "settings": [
        {
        "type": "image_picker",
        "id": "image",
        "label": "Image"
       }
      ]
    }
  ],
  "presets": [
    {
      "name": "App image text",
      "blocks": [
        {
          "type": "heading"
        },
        {
          "type": "text"
        },
        {
          "type": "button"
        }
      ]
    }
  ]
}
{% endschema %}
